﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XQ.Framework.core;
using XQ.Framework.data;
using XQ.Framework.html;
using XQ.Framework.model;

namespace XQ.Framework.Base.Bll
{
    /// <summary>
    /// Summary description for BaseBll
    /// </summary>
    public abstract class BaseBll<T> : SingleDB, IBaseBll<T> where T : class,new()
    {
        public bool UseCache { get; set; }

        public BaseBll()
        {
            UseCache = true;
        }

        public void Dispose()
        {
            this.ReleaseDataBase();
        }

        //#region 存储页面数据
        //public readonly IDictionary<string, object> data = new Dictionary<string, object>();
        //public virtual List<string> getKeysList()
        //{
        //    return data.Keys.ToList();
        //}
        //public virtual void SetPageData(string key, object value)
        //{
        //    key = ConvertHelper.getString(key);
        //    if (data.Keys.Contains(key))
        //    {
        //        data.Remove(key);
        //    }
        //    if (value == null) { return; }
        //    this.data.Add(key, value);
        //}
        //public virtual object GetPageData(string key)
        //{
        //    key = ConvertHelper.getString(key);
        //    if (data == null || !data.Keys.Contains(key)) { return null; }
        //    return data[key];
        //}
        //public virtual string this[string key]
        //{
        //    get
        //    {
        //        return GetPageDataString(key);
        //    }
        //    set
        //    {
        //        SetPageData(key, value);
        //    }
        //}
        //public virtual string GetPageDataString(string key)
        //{
        //    return ConvertHelper.getString(GetPageData(key));
        //}
        //public virtual IDictionary<string, object> FillData(IDictionary<string, object> dataContainer)
        //{
        //    if (dataContainer == null) { dataContainer = new Dictionary<string, object>(); }
        //    this.data.Keys.ToList().ForEach(delegate(string key)
        //    {
        //        if (!dataContainer.Keys.Contains(key))
        //        {
        //            dataContainer.Add(key, this.data[key]);
        //        }
        //    });
        //    ClearData();
        //    return dataContainer;
        //}
        //public virtual void ClearData()
        //{
        //    this.data.Clear();
        //}
        //#endregion

        //#region 基础的增删改查
        //public virtual int Add(T model)
        //{
        //    IDictionary<string, string> data = ReflectionHelper.ObjectToDictionary(model);
        //    return -1;
        //}

        //public virtual int Delete(params string[] id)
        //{
        //    return -1;
        //}

        //public virtual int Update(T model, string id)
        //{
        //    return -1;
        //}

        //public virtual T Query(string id)
        //{
        //    return null;
        //}

        //public virtual IList<T> QueryLimit(int start, int count)
        //{
        //    return null;
        //}
        //#endregion
    }
}
